<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增机具采购、退款')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-agentPosOperation-add">
            <h4 class="form-header h4" >购机服务商信息</h4>
            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label  is-required">服务商编号：</label>
                    <div class="col-sm-8">
                        <input name="topAgentNum" onclick="selectAgentInfoListData()" readonly id="applyAgentNum" type="text" class="form-control" required>
                        <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">服务商名称：</label>
                    <div class="col-sm-8">
                        <input name="topAgentName" class="form-control" id="applyAgentName" type="text" required readonly>
                    </div>
                </div>
                <div class="form-group" style="display: none">
                    <label class="col-sm-3 control-label">团类型：</label>
                    <div class="col-sm-8">
                        <select name="teamType" class="form-control m-b">
                            <option value="1">老团</option>
                            <option value="2">新团</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">打款类型：</label>
                    <div class="col-sm-8">
                        <select name="rewardType" class="form-control m-b">
                            <option value="">所有</option>
                            <option value="3">2元</option>
                            <option value="1">4元</option>
                            <option value="2">8元</option>
                        </select>
                    </div>
                </div>
            </div>
            <div style="display: none">
                <h4 class="form-header h4" >返现展业端管理信息</h4>
                <div class="row">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">返现展业端管理编号：</label>
                        <div class="col-sm-8">
                            <input name="agentNum" onclick="selectAgentInfoRecursiveData()" readonly id="targetAgentNum" type="text" class="form-control" >
                            <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">返现展业端管理名称：</label>
                        <div class="col-sm-8">
                            <input name="agentName" class="form-control" id="targetAgentName" type="text" readonly>
                        </div>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4" >终端信息</h4>
            <div class="row">
            <div class="form-group">
                <label class="col-sm-3 control-label">终端单价：</label>
                <div class="col-sm-8">
                    <input name="oneMoney" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">终端数量：</label>
                <div class="col-sm-8">
                    <input name="num" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">总付款金额：</label>
                <div class="col-sm-8">
                    <input name="allMoney" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">终端类型：</label>
                <div class="col-sm-8">
                    <select name="posType" class="form-control m-b">
                        <option value="">所有</option>
                        <option value="4">电签</option>
                        <option value="0">传统</option>
                        <option value="5">GB传统</option>
                    </select>
                </div>
            </div>
        </div>
            <h4 class="form-header h4" >打款信息</h4>
           <div class="row">
               <div class="form-group">
                   <label class="col-sm-3 control-label">打款方式：</label>
                   <div class="col-sm-8">
                       <select name="dkWay" class="form-control m-b">
                           <option value="">所有</option>
                           <option value="1">现金</option>
                           <option value="2">pos</option>
                           <option value="3">网银</option>
                       </select>
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-sm-3 control-label">打款人：</label>
                   <div class="col-sm-8">
                       <input name="dkMan" minlength="1" maxlength="6" class="form-control" type="text">
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-sm-3 control-label">打款时间：</label>
                   <div class="col-sm-8">
                       <div class="input-group date">
                           <input name="dkDate" class="form-control" readonly placeholder="yyyy-MM-dd" type="text">
                           <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                       </div>
                   </div>
               </div>
               <div class="form-group">
                   <label  class="col-sm-3 control-label is-required" >上传凭证:</label>
                   <br/>
                   <div class="col-sm-8">
                       <div class="fileinput fileinput-new" data-provides="fileinput">
                           <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
                           <div>
                               <span class="btn btn-white btn-file"><span class="fileinput-new">选择图片</span><span class="fileinput-exists">更改</span><input  name="pzImg" type="file"></span>
                               <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                           </div>
                       </div>
                   </div>
               </div>
           </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:inline="javascript">
        var prefix = ctx + "agentPosOperation/agentPosOperation"
        var prefixA= ctx + "AgentMarketingReward/AgentMarketingReward";
        $("#form-agentPosOperation-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                //打款凭证
                var detailImg = $("input[name='pzImg']").val();
                if (detailImg == ''){
                    $.modal.alertError("请上传打款凭证");
                    return;
                }

                var formData = new FormData($("#form-agentPosOperation-add")[0]);
                $.ajax({
                    url: prefix + "/add",
                    data: formData,
                    type: "post",
                    cache: false,
                    dataType: "json",
                    cache: false,//上传文件无需缓存
                    processData: false,//用于对data参数进行序列化处理 这里必须false
                    contentType: false, //必须
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            $.operate.successCallback(result);
                        }else {
                            $.modal.alertError(result.msg);
                        }
                        $.modal.closeLoading();
                    },
                })
            }
        }

        $("input[name='dkDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='examineDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        /**
         * 选择服务商
         */
        function selectAgentInfoListData() {
            var url =prefix+ "/selectAgentInfoAllList";
            $.modal.open("选择服务商" , url, '1100',"500");
        }


        /**
         * 选择本级级以下代理
         */
        function selectAgentInfoRecursiveData() {
            var agentNum = $("#applyAgentNum").val();
            if ($.common.isEmpty(agentNum)){
                $.modal.alertWarning("请选择申请资深总监");
                return;
            }
            var url =prefix+ "/selectAgentInfoList?agentNum="+agentNum;
            $.modal.open("选择下级服务商" , url, '1100',"500");
        }

    </script>
</body>
</html>